#ifndef __STDMYSQL_H_
#define __STDMYSQL_H_

#include <mysql/mysql.h>
#include <string>
#include <vector>
#include <iostream>

using CStrRef = const std::string &;
using StrMatrix = std::vector<std::vector<std::string>>;

class StdMySql
{
public:
    StdMySql();
    ~StdMySql();
    // 连接
    bool Connect(CStrRef host,CStrRef user,CStrRef passwd,CStrRef dbName,int port = 3306);
    //执行sql语句
    bool Exec(CStrRef sql);
    //获取查询结果
    StrMatrix GetSqlResult(CStrRef sql);
    //事务
    bool StartTransaction();
    bool Commit();//提交
    bool Rollback();//回滚

private:
    MYSQL mysql;
    bool isConnected;
};

#endif